'''
Created on 11/12/2012

@author: greis
'''
#!/bin/python
import random

# Complete the function below to print 2 integers separated by a single space which will be your next move 
# def nextMove(player,board):
def nextMove(player,board):
    count = 0
    newBoard = []
    moveLine = ''
    moveColumn = ''
    if player == 'X':
        for i in xrange(0, 3):#line in board:
            line = board[i]
            newLine = ""
            for j in xrange(0, 3):#column in line:
                column = line[j]
                if column == '_' and count == 0:
                    newLine += 'X' 
                    moveLine = i
                    moveColumn = j
                    count = 1 
                else:
                    newLine += column
            newBoard.append(newLine)
        #board = newBoard
        #player = 'O'
        print str(moveLine)+" "+str(moveColumn) #newBoard
    elif player == 'O':
        for i in xrange(0, 3):#line in board:
            line = board[i]
            newLine = ""
            for j in xrange(0, 3):#column in line:
                column = line[j]
                if column == '_' and count == 0:
                    newLine += 'O' 
                    moveLine = i
                    moveColumn = j
                    count = 1 
                else:
                    newLine += column
            newBoard.append(newLine)
        #board = newBoard
        #player = 'X'
        print str(moveLine)+" "+str(moveColumn) #newBoard
    
     

#If player is X, I'm the first player.
#If player is O, I'm the second player.
player = raw_input()

#Read the board now. The board is a 3x3 array filled with X, O or _.
board = []
for i in xrange(0, 3):
    board.append(raw_input())

nextMove(player,board)  
